What is the Difference Between an Xbasic Module and an Xbasic Function Library?

Description

While an Xbasic Function Library and Xbasic Module may seem to be the same thing, the two Xbasic constructs have several key differences.

Discussion

On the surface an Xbasic Function Library and an Xbasic Module seem similar in that they are both files in which you can define multiple Xbasic functions. However, there are several key differences between the two approaches.

Xbasic Module

Xbasic Function

Included using the require() function

Included using the Xbasic Linked Files property in the component or using compile_Xbasic_function_library()

Can only call functions made publicly available using the exports keyword

All functions are publicly available

Always loaded into its own namespace

Loaded into the same namespace as locally defined functions in a component (unless explicitly loaded into a namespace using compile_Xbasic_function_library())

Functions must be called using the namespace prefix

Functions can be called as if they were defined locally (unless explicitly loaded into a namespace using compile_Xbasic_function_library())

See Also